package com.gitee.swsk33.algorithms.search;

import com.gitee.swsk33.algorithms.tree.binarytree.BinaryTree;

import java.util.List;

/**
 * 查找算法测试主类
 */
public class Main {

	public static void main(String[] args) {
		int[] originList = {45, 12, 3, 37, 24, 100, 53, 61, 90, 78};
		BinaryTree<Integer> tree = BinarySortTree.createSortTree(originList);
		List<Integer> preList = tree.preorderTraversal();
		List<Integer> inList = tree.inorderTraversal();
		// 打印先序遍历
		for (int i : preList) {
			System.out.print(i + " ");
		}
		System.out.println();
		// 打印中序遍历
		for (int i : inList) {
			System.out.print(i + " ");
		}
		System.out.println();
		// 删除一个结点试试
		BinarySortTree.deleteNode(tree, 45);
		preList = tree.preorderTraversal();
		inList = tree.inorderTraversal();
		// 打印先序遍历
		for (int i : preList) {
			System.out.print(i + " ");
		}
		System.out.println();
		// 打印中序遍历
		for (int i : inList) {
			System.out.print(i + " ");
		}
	}

}